package org.xi.behavioral.chainofresponsibility;

import org.xi.behavioral.chainofresponsibility.logger.*;

/**
 * 责任链模式
 */
public class Main {

    public static void main(String[] args) {
        AbstractLogger errorLogger = new ErrorLogger(1);
        AbstractLogger warnLogger = new WarnLogger(2);
        AbstractLogger infoLogger = new InfoLogger(3);
        AbstractLogger debugLogger = new DebugLogger(4);

        errorLogger.setNextLogger(warnLogger);
        warnLogger.setNextLogger(infoLogger);
        infoLogger.setNextLogger(debugLogger);

        errorLogger.logMessage(4, "This is a debug message.");
        errorLogger.logMessage(3, "This is an info message.");

        warnLogger.logMessage(4, "This is a debug message.");
        warnLogger.logMessage(3, "This is an info message.");

        debugLogger.logMessage(4, "This is a debug message.");
        debugLogger.logMessage(3, "This is an info message.");
    }
}
